package com.learn.design.strategy.example;

import org.springframework.stereotype.Component;

/**
 * @author Administrator
 */
@Component
public class FormModelSubmitHandler implements FormSubmitHandler<Long> {


    @Override
    public String getSubmitType() {
        return "model";
    }

    @Override
    public CommonPairResponse<String, Long> handleSubmit(FormSubmitRequest request) {
        System.out.printf("模型提交：userId=%s, formInput=%s%n", request.getUserId(), request.getFormInput());

        // 模型创建成功后获得模型的 id
        Long modelId = createModel(request);
        return CommonPairResponse.success("模型提交成功！", modelId);
    }

    private Long createModel(FormSubmitRequest request) {
        // 创建模型的逻辑
        return 123L;
    }
}
